<?php
declare (strict_types=1);

namespace Plugin\Alarm\Model;

use Mine\MineModel;
use Plugin\Alarm\Model\RdAlarmDanger;

class RdAlarmDangerType extends MineModel
{
    /**
     * The table associated with the model.
     *
     * @var string|null
     */
    protected ?string $table = 'rd_alarm_danger_type';
    
    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */
    protected array $fillable = [
        'id', 'name', 'icon', 'description', 'created_at', 'updated_at'
    ];
    
    /**
     * The attributes that should be cast to native types.
     *
     * @var array
     */
    protected array $casts = [
        'id' => 'integer',
        'name' => 'string',
        'icon' => 'string',
        'description' => 'string',
        'created_at' => 'datetime',
        'updated_at' => 'datetime',
    ];
    
    /**
     * 关联隐患信息
     */
    public function dangers()
    {
        return $this->hasMany(RdAlarmDanger::class, 'type', 'id');
    }
}